from sample.student import Student


class StudentManager:
    def __init__(self):
        self.stu_list = []

    def run(self):
        while True:
            # 1,调用显示功能界面菜单函数
            self.menu()
            # 2.让输入选择
            num = input('请输入您需要的功能编号：')
            # 3.根据用户输入进入不同的功能函数
            if num == 'i':
                self.add_stu()
            elif num == '2':
                self.del_stu()
            elif num == '3':
                self.modify_stu()
            elif num == '4':
                self.search_stu()
            elif num == '5':
                self.show()
            elif num == '6':
                self.save_stu()
            elif num == '7':
                break
            else:
                print('输入有误！')

    def menu(self):
        print('-' * 20)
        print('请选择功能菜单')
        print('1：添加学员')
        print('2：删除学院')
        print('3：修改学员')
        print('4：搜索学员')
        print('5：显示所有学员')
        print('6：保存学员信息')
        print('7：退出系统')
        print('-' * 20)

    def add_stu(self):
        print('--------添加功能-----------')
        name = input('请输入学员姓名：')
        gender = input('请输入学员性别：')
        tel = input('请输入学员电话：')
        stu = Student(name, gender, tel)
        self.stu_list.append(stu)
        print('添加成功')

    def save_stu(self):
        with open('data.txt','w') as f:
            new_list = [e.__dict__ for e in self.stu_list]

            f.write(str(new_list))

    def add_stu(self):
        pass

    def del_stu(self):
        pass

    def modify_stu(self):
        pass

    def search_stu(self):
        pass

    def show(self):
        pass
